<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE BangPatterns #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-comment">--</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- (c) The University of Glasgow 2003-2006</span><span>
</span><span id="line-5"></span><span class="hs-comment">--</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Functions for constructing bitmaps, which are used in various</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- places in generated code (stack frame liveness masks, function</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- argument liveness masks, SRT bitmaps).</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Data.Bitmap</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-12"></span><span>        </span><span class="annot"><a href="GHC.Data.Bitmap.html#Bitmap"><span class="hs-identifier">Bitmap</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bitmap.html#mkBitmap"><span class="hs-identifier">mkBitmap</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-13"></span><span>        </span><span class="annot"><a href="GHC.Data.Bitmap.html#intsToReverseBitmap"><span class="hs-identifier">intsToReverseBitmap</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Data.Bitmap.html#mAX_SMALL_BITMAP_SIZE"><span class="hs-identifier">mAX_SMALL_BITMAP_SIZE</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-16"></span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html"><span class="hs-identifier">GHC.Runtime.Heap.Layout</span></a></span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#"><span class="hs-identifier">Data.Bits</span></a></span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-comment">{-|
A bitmap represented by a sequence of 'StgWord's on the /target/
architecture.  These are used for bitmaps in info tables and other
generated code which need to be emitted as sequences of StgWords.
-}</span><span>
</span><span id="line-29"></span><span class="hs-keyword">type</span><span> </span><span id="Bitmap"><span class="annot"><a href="GHC.Data.Bitmap.html#Bitmap"><span class="hs-identifier hs-var">Bitmap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#StgWord"><span class="hs-identifier hs-type">StgWord</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span class="hs-comment">-- | Make a bitmap from a sequence of bits</span><span>
</span><span id="line-32"></span><span class="annot"><a href="GHC.Data.Bitmap.html#mkBitmap"><span class="hs-identifier hs-type">mkBitmap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bitmap.html#Bitmap"><span class="hs-identifier hs-type">Bitmap</span></a></span><span>
</span><span id="line-33"></span><span id="mkBitmap"><span class="annot"><span class="annottext">mkBitmap :: Platform -&gt; [Bool] -&gt; Bitmap
</span><a href="GHC.Data.Bitmap.html#mkBitmap"><span class="hs-identifier hs-var hs-var">mkBitmap</span></a></span></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-34"></span><span class="annot"><a href="GHC.Data.Bitmap.html#mkBitmap"><span class="hs-identifier hs-var">mkBitmap</span></a></span><span> </span><span id="local-6989586621680945350"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945350"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621680945349"><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680945349"><span class="hs-identifier hs-var">stuff</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; [Bool] -&gt; StgWord
</span><a href="GHC.Data.Bitmap.html#chunkToBitmap"><span class="hs-identifier hs-var">chunkToBitmap</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945350"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680945347"><span class="hs-identifier hs-var">chunk</span></a></span><span> </span><span class="annot"><span class="annottext">StgWord -&gt; Bitmap -&gt; Bitmap
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Platform -&gt; [Bool] -&gt; Bitmap
</span><a href="GHC.Data.Bitmap.html#mkBitmap"><span class="hs-identifier hs-var">mkBitmap</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945350"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680945346"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-35"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680945347"><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680945347"><span class="hs-identifier hs-var">chunk</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680945346"><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680945346"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [Bool] -&gt; ([Bool], [Bool])
forall a. Int -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/GHC.List.html#splitAt"><span class="hs-identifier hs-var">splitAt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Int
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSizeInBits"><span class="hs-identifier hs-var">platformWordSizeInBits</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945350"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680945349"><span class="hs-identifier hs-var">stuff</span></a></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="annot"><a href="GHC.Data.Bitmap.html#chunkToBitmap"><span class="hs-identifier hs-type">chunkToBitmap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#StgWord"><span class="hs-identifier hs-type">StgWord</span></a></span><span>
</span><span id="line-38"></span><span id="chunkToBitmap"><span class="annot"><span class="annottext">chunkToBitmap :: Platform -&gt; [Bool] -&gt; StgWord
</span><a href="GHC.Data.Bitmap.html#chunkToBitmap"><span class="hs-identifier hs-var hs-var">chunkToBitmap</span></a></span></span><span> </span><span id="local-6989586621680945343"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945343"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621680945342"><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680945342"><span class="hs-identifier hs-var">chunk</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-39"></span><span>  </span><span class="annot"><span class="annottext">(StgWord -&gt; StgWord -&gt; StgWord) -&gt; StgWord -&gt; Bitmap -&gt; StgWord
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">StgWord -&gt; StgWord -&gt; StgWord
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator hs-var">(.|.)</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Integer -&gt; StgWord
</span><a href="GHC.Runtime.Heap.Layout.html#toStgWord"><span class="hs-identifier hs-var">toStgWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945343"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Int -&gt; StgWord
</span><a href="#local-6989586621680945338"><span class="hs-identifier hs-var">oneAt</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945337"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">,</span><span id="local-6989586621680945337"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945337"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Bool] -&gt; [Int] -&gt; [(Bool, Int)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680945342"><span class="hs-identifier hs-var">chunk</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-40"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-41"></span><span>    </span><span class="annot"><a href="#local-6989586621680945338"><span class="hs-identifier hs-type">oneAt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#StgWord"><span class="hs-identifier hs-type">StgWord</span></a></span><span>
</span><span id="line-42"></span><span>    </span><span id="local-6989586621680945338"><span class="annot"><span class="annottext">oneAt :: Int -&gt; StgWord
</span><a href="#local-6989586621680945338"><span class="hs-identifier hs-var hs-var">oneAt</span></a></span></span><span> </span><span id="local-6989586621680945336"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945336"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Integer -&gt; StgWord
</span><a href="GHC.Runtime.Heap.Layout.html#toStgWord"><span class="hs-identifier hs-var">toStgWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945343"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">StgWord -&gt; Int -&gt; StgWord
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="../../base/src/Data.Bits.html#shiftL"><span class="hs-operator hs-var">`shiftL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945336"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-comment">-- | Make a bitmap where the slots specified are the /zeros/ in the bitmap.</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- eg. @[0,1,3], size 4 ==&gt; 0x4@  (we leave any bits outside the size as zero,</span><span>
</span><span id="line-46"></span><span class="hs-comment">-- just to make the bitmap easier to read).</span><span>
</span><span id="line-47"></span><span class="hs-comment">--</span><span>
</span><span id="line-48"></span><span class="hs-comment">-- The list of @Int@s /must/ be already sorted and duplicate-free.</span><span>
</span><span id="line-49"></span><span class="annot"><a href="GHC.Data.Bitmap.html#intsToReverseBitmap"><span class="hs-identifier hs-type">intsToReverseBitmap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-50"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>      </span><span class="hs-comment">-- ^ size in bits</span><span>
</span><span id="line-51"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- ^ sorted indices of zeros free of duplicates</span><span>
</span><span id="line-52"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bitmap.html#Bitmap"><span class="hs-identifier hs-type">Bitmap</span></a></span><span>
</span><span id="line-53"></span><span id="intsToReverseBitmap"><span class="annot"><span class="annottext">intsToReverseBitmap :: Platform -&gt; Int -&gt; [Int] -&gt; Bitmap
</span><a href="GHC.Data.Bitmap.html#intsToReverseBitmap"><span class="hs-identifier hs-var hs-var">intsToReverseBitmap</span></a></span></span><span> </span><span id="local-6989586621680945334"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945334"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621680945333"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945333"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [Int] -&gt; Bitmap
</span><a href="#local-6989586621680945332"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-54"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-55"></span><span>    </span><span id="local-6989586621680945331"><span class="annot"><span class="annottext">word_sz :: Int
</span><a href="#local-6989586621680945331"><span class="hs-identifier hs-var hs-var">word_sz</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Int
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSizeInBits"><span class="hs-identifier hs-var">platformWordSizeInBits</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945334"><span class="hs-identifier hs-var">platform</span></a></span><span>
</span><span id="line-56"></span><span>    </span><span class="annot"><a href="#local-6989586621680945330"><span class="hs-identifier hs-type">oneAt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#StgWord"><span class="hs-identifier hs-type">StgWord</span></a></span><span>
</span><span id="line-57"></span><span>    </span><span id="local-6989586621680945330"><span class="annot"><span class="annottext">oneAt :: Int -&gt; StgWord
</span><a href="#local-6989586621680945330"><span class="hs-identifier hs-var hs-var">oneAt</span></a></span></span><span> </span><span id="local-6989586621680945329"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945329"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Integer -&gt; StgWord
</span><a href="GHC.Runtime.Heap.Layout.html#toStgWord"><span class="hs-identifier hs-var">toStgWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945334"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">StgWord -&gt; Int -&gt; StgWord
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="../../base/src/Data.Bits.html#shiftL"><span class="hs-operator hs-var">`shiftL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945329"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-58"></span><span>
</span><span id="line-59"></span><span>    </span><span class="hs-comment">-- It is important that we maintain strictness here.</span><span>
</span><span id="line-60"></span><span>    </span><span class="hs-comment">-- See Note [Strictness when building Bitmaps].</span><span>
</span><span id="line-61"></span><span>    </span><span class="annot"><a href="#local-6989586621680945332"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Bitmap.html#Bitmap"><span class="hs-identifier hs-type">Bitmap</span></a></span><span>
</span><span id="line-62"></span><span>    </span><span id="local-6989586621680945332"><span class="annot"><span class="annottext">go :: Int -&gt; [Int] -&gt; Bitmap
</span><a href="#local-6989586621680945332"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680945328"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945328"><span class="hs-identifier hs-var">pos</span></a></span></span><span> </span><span id="local-6989586621680945327"><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621680945327"><span class="hs-identifier hs-var">slots</span></a></span></span><span>
</span><span id="line-63"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945333"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945328"><span class="hs-identifier hs-var">pos</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-64"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-65"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(StgWord -&gt; StgWord -&gt; StgWord) -&gt; StgWord -&gt; Bitmap -&gt; StgWord
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">StgWord -&gt; StgWord -&gt; StgWord
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#xor"><span class="hs-identifier hs-var">xor</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Integer -&gt; StgWord
</span><a href="GHC.Runtime.Heap.Layout.html#toStgWord"><span class="hs-identifier hs-var">toStgWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945334"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621680945324"><span class="hs-identifier hs-var">init</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Int -&gt; StgWord) -&gt; [Int] -&gt; Bitmap
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680945323"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945323"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-glyph">-&gt;</span><span class="annot"><span class="annottext">Int -&gt; StgWord
</span><a href="#local-6989586621680945330"><span class="hs-identifier hs-var">oneAt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945323"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945328"><span class="hs-identifier hs-var">pos</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621680945322"><span class="hs-identifier hs-var">these</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">StgWord -&gt; Bitmap -&gt; Bitmap
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span>
</span><span id="line-66"></span><span>          </span><span class="annot"><span class="annottext">Int -&gt; [Int] -&gt; Bitmap
</span><a href="#local-6989586621680945332"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945328"><span class="hs-identifier hs-var">pos</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945331"><span class="hs-identifier hs-var">word_sz</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621680945320"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-67"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-68"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680945322"><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621680945322"><span class="hs-identifier hs-var">these</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680945320"><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621680945320"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Bool) -&gt; [Int] -&gt; ([Int], [Int])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/GHC.List.html#span"><span class="hs-identifier hs-var">span</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945328"><span class="hs-identifier hs-var">pos</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945331"><span class="hs-identifier hs-var">word_sz</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621680945327"><span class="hs-identifier hs-var">slots</span></a></span><span>
</span><span id="line-69"></span><span>        </span><span id="local-6989586621680945314"><span class="annot"><span class="annottext">remain :: Int
</span><a href="#local-6989586621680945314"><span class="hs-identifier hs-var hs-var">remain</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945333"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945328"><span class="hs-identifier hs-var">pos</span></a></span><span>
</span><span id="line-70"></span><span>        </span><span id="local-6989586621680945324"><span class="annot"><span class="annottext">init :: Integer
</span><a href="#local-6989586621680945324"><span class="hs-identifier hs-var hs-var">init</span></a></span></span><span>
</span><span id="line-71"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945314"><span class="hs-identifier hs-var">remain</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945331"><span class="hs-identifier hs-var">word_sz</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span>
</span><span id="line-72"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Int -&gt; Integer
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="../../base/src/Data.Bits.html#shiftL"><span class="hs-operator hs-var">`shiftL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680945314"><span class="hs-identifier hs-var">remain</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Integer
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">1</span></span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-comment">{-

Note [Strictness when building Bitmaps]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

One of the places where @Bitmap@ is used is in building Static Reference
Tables (SRTs) (in @GHC.Cmm.Info.Build.procpointSRT@). In #7450 it was noticed
that some test cases (particularly those whose C-- have large numbers of CAFs)
produced large quantities of allocations from this function.

The source traced back to 'intsToBitmap', which was lazily subtracting the word
size from the elements of the tail of the @slots@ list and recursively invoking
itself with the result. This resulted in large numbers of subtraction thunks
being built up. Here we take care to avoid passing new thunks to the recursive
call. Instead we pass the unmodified tail along with an explicit position
accumulator, which get subtracted in the fold when we compute the Word.

-}</span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-comment">{- |
Magic number, must agree with @BITMAP_BITS_SHIFT@ in InfoTables.h.
Some kinds of bitmap pack a size\/bitmap into a single word if
possible, or fall back to an external pointer when the bitmap is too
large.  This value represents the largest size of bitmap that can be
packed into a single word.
-}</span><span>
</span><span id="line-100"></span><span class="annot"><a href="GHC.Data.Bitmap.html#mAX_SMALL_BITMAP_SIZE"><span class="hs-identifier hs-type">mAX_SMALL_BITMAP_SIZE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-101"></span><span id="mAX_SMALL_BITMAP_SIZE"><span class="annot"><span class="annottext">mAX_SMALL_BITMAP_SIZE :: Platform -&gt; Int
</span><a href="GHC.Data.Bitmap.html#mAX_SMALL_BITMAP_SIZE"><span class="hs-identifier hs-var hs-var">mAX_SMALL_BITMAP_SIZE</span></a></span></span><span> </span><span id="local-6989586621680945304"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945304"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-102"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; PlatformWordSize
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSize"><span class="hs-identifier hs-var hs-var">platformWordSize</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945304"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-103"></span><span>      </span><span class="annot"><span class="annottext">PlatformWordSize
</span><a href="../../ghc-boot/src/GHC.Platform.html#PW4"><span class="hs-identifier hs-var">PW4</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">27</span></span><span> </span><span class="hs-comment">-- On 32-bit: 5 bits for size, 27 bits for bitmap</span><span>
</span><span id="line-104"></span><span>      </span><span class="annot"><span class="annottext">PlatformWordSize
</span><a href="../../ghc-boot/src/GHC.Platform.html#PW8"><span class="hs-identifier hs-var">PW8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">58</span></span><span> </span><span class="hs-comment">-- On 64-bit: 6 bits for size, 58 bits for bitmap</span><span>
</span><span id="line-105"></span></pre></body></html>